package com.csk.zsk.compents.dao.impl;

import java.util.List;
import org.springframework.stereotype.Repository;
import com.csk.zsk.commons.dao.impl.BaseHibernateDao;
import com.csk.zsk.compents.dao.WeatherCodeDao;
import com.csk.zsk.compents.entity.WeatherCode;
@Repository
public class WeatherCodeDaoImpl extends BaseHibernateDao<WeatherCode, String> implements WeatherCodeDao {

	@Override
	public List<WeatherCode> getWeatherCodeListByLevel(String level) {
		return this.findBy("level", level);
		
	}

	@Override
	public List<WeatherCode> getSubWeatherCodeList(String code) {
		return this.createQuery("from WeatherCode wc where wc.citycode like '"+code+"%'").list();
	}

	@Override
	public WeatherCode getWeatherCodeByName(String cityname, String level) {
		List<WeatherCode> list = this.createQuery("from WeatherCode wc where wc.level='"+level+"' and wc.cityname = '"+cityname+"' ").setMaxResults(1).list();
		if(list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}

	

}
